"use strict";

require("core-js/modules/es.array.index-of");

require("core-js/modules/es.object.assign");

require("core-js/modules/es.regexp.exec");

require("core-js/modules/es.string.split");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

/*
 * Copyright (C) 2016 Bilibili. All Rights Reserved.
 *
 * @author zheng qian <xqq@xqq.im>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
var Browser = {};

function detect() {
  // modified from jquery-browser-plugin
  var ua = typeof self == 'undefined' ? "" : self.navigator.userAgent.toLowerCase();
  var match = /(edge)\/([\w.]+)/.exec(ua) || /(opr)[\/]([\w.]+)/.exec(ua) || /(chrome)[ \/]([\w.]+)/.exec(ua) || /(iemobile)[\/]([\w.]+)/.exec(ua) || /(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(ua) || /(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(ua) || /(webkit)[ \/]([\w.]+)/.exec(ua) || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || /(msie) ([\w.]+)/.exec(ua) || ua.indexOf('trident') >= 0 && /(rv)(?::| )([\w.]+)/.exec(ua) || ua.indexOf('compatible') < 0 && /(firefox)[ \/]([\w.]+)/.exec(ua) || [];
  var platform_match = /(ipad)/.exec(ua) || /(ipod)/.exec(ua) || /(windows phone)/.exec(ua) || /(iphone)/.exec(ua) || /(kindle)/.exec(ua) || /(android)/.exec(ua) || /(windows)/.exec(ua) || /(mac)/.exec(ua) || /(linux)/.exec(ua) || /(cros)/.exec(ua) || [];
  var matched = {
    browser: match[5] || match[3] || match[1] || '',
    version: match[2] || match[4] || '0',
    majorVersion: match[4] || match[2] || '0',
    platform: platform_match[0] || ''
  };
  var browser = {};

  if (matched.browser) {
    browser[matched.browser] = true;
    var versionArray = matched.majorVersion.split('.');
    browser.version = {
      major: parseInt(matched.majorVersion, 10),
      string: matched.version
    };

    if (versionArray.length > 1) {
      browser.version.minor = parseInt(versionArray[1], 10);
    }

    if (versionArray.length > 2) {
      browser.version.build = parseInt(versionArray[2], 10);
    }
  }

  if (matched.platform) {
    browser[matched.platform] = true;
  }

  if (browser.chrome || browser.opr || browser.safari) {
    browser.webkit = true;
  } // MSIE. IE11 has 'rv' identifer


  if (browser.rv || browser.iemobile) {
    if (browser.rv) {
      delete browser.rv;
    }

    var msie = 'msie';
    matched.browser = msie;
    browser[msie] = true;
  } // Microsoft Edge


  if (browser.edge) {
    delete browser.edge;
    var msedge = 'msedge';
    matched.browser = msedge;
    browser[msedge] = true;
  } // Opera 15+


  if (browser.opr) {
    var opera = 'opera';
    matched.browser = opera;
    browser[opera] = true;
  } // Stock android browsers are marked as Safari


  if (browser.safari && browser.android) {
    var android = 'android';
    matched.browser = android;
    browser[android] = true;
  }

  browser.name = matched.browser;
  browser.platform = matched.platform;

  for (var key in Browser) {
    if (Browser.hasOwnProperty(key)) {
      delete Browser[key];
    }
  }

  Object.assign(Browser, browser);
}

detect();
var _default = Browser;
exports.default = _default;